﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Sockets;

namespace Server
{
    public partial class frmTools : Form
    {
        public frmTools()
        {
            InitializeComponent();
        }

        public Dictionary<string, Socket> ds { get; set; }

        /// <summary>
        /// LODE
        /// </summary>
        private void frmTools_Load(object sender, EventArgs e)
        {
            if (ds.Count > 0)
            {
                foreach (var item in ds)
                {
                    this.dgvClient.Rows.Add(new object[]
                    {
                       item.Key
                    });
                }
                
            }
        }

        /// <summary>
        /// 发送
        /// </summary>
        private void btnSeting_Click(object sender, EventArgs e)
        {
            string sKey = this.dgvClient.SelectedRows[0].Cells[0].Value.ToString();
            Socket skt = ds[sKey];
            byte[] b_Send = System.Text.Encoding.ASCII.GetBytes(txtMeg.Text.Trim());
            skt.Send(b_Send);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            string sKey = this.dgvClient.SelectedRows[0].Cells[0].Value.ToString();
            Socket skt = ds[sKey];
            skt.Close();
            this.dgvClient.Rows.Remove(this.dgvClient.SelectedRows[0]);
            BaseEvent.ConnectionCount(false);
        }




    }
}
